<?php
/**
 * Created by PhpStorm.
 * User: chenyeubin
 * Date: 2020\2\27 0027
 * Time: 14:51
 */

namespace console\controllers;

use Yii;
use yii\console\Controller;
use yii\web\HttpException;

class OssController extends Controller
{
    /**
     * 定时上传本地文件到oss
     * @return bool
     * @throws HttpException
     * @throws \OSS\Core\OssException
     * @author chenyuebin
     */
    public function actionOssUpload()
    {
        try {
            Yii::$app->services->patientClinicImg->addClinicImg();
            echo 'success';
        } catch (\Exception $exception) {
            echo 'error:' . $exception;
        }
    }

    /**
     * 修复图片缺失的上传日期
     * @author chenyuebin
     */
    public function actionOssDateRepair()
    {
        try {
            $res = Yii::$app->services->patientClinicImg->ClinicImgRepair();
            echo 'success';
        } catch (\Exception $exception) {
            echo 'error:' . $exception;
        }
    }

    /**
     * 白白管家图片上传
     * @author chenyuebin
     */
    public function actionBaibaiImgUpload()
    {
        try {
            $ret = Yii::$app->services->patientClinicImg->baibaiImgUpload();
            print_r($ret);
            echo 'success';
        } catch (\Exception $exception) {
            echo 'error:' . $exception;
        }
    }

    /**
     * 白白管家患者签名图片上传
     * @author chenyuebin
     */
    public function actionBaibaiSignImgUpload()
    {
        try {
            Yii::$app->services->patientClinicImg->baibaiSignImgUpload();
            echo 'success';
        } catch (\Exception $exception) {
            echo 'error:' . $exception;
        }
    }

    /**
     * @Notes: 恢复patient_clinic_img数据【针对定时删除本地服务器图片-清理15天前的数据的修复脚本】
     *
     * 此脚本将会查询 by_oss_attachment 表数据
     * 此脚本将会向 by_patient_clinic_img 表插入数据
     *
     * @Interface actionRepairClinicImg
     * @author: chenyuebin
     * @Time: 2022/5/4 0004   15:10
     */
    public function actionRepairClinicImg()
    {
        try {
            Yii::$app->services->patientClinicImg->repairClinicImg();
        } catch (\Exception $exception) {
            echo 'error:' . $exception;
        }
    }
}